********************************************************
* This replication file makes the "Indicators.dta" dataset
* for the MCMC analysis.
* Jonathan K. Hanson and Rachel Sigman, "Leviathan's Latent Dimensions:
* Measuring State Capacity for Comparative Political Research"
* Journal of Politics, forthcoming 2021
********************************************************

** Gaussian Variables for Test
* censusfreq
* StateHist
* tax_inc_tax
* tax_trade_tax
* taxrev_gdp
* weberian
* wbstat
* v2terr 
* v2clrspct 
* v2stfisccap
* infcap
* policecap
* milpercap
* milexpercap
* bureau_qual (obtain from Political Risk Services) 
* law_order (obtain from Political Risk Services)

** Poisson Variables
* irai_erm
* irai_qbfm
* irai_qpa
* AdmEffic
* bti_mo


* GDPcap for missingness equation.

clear
*cd ""

use "Data/HansonSigman_source.dta"

drop if sample_polity == 0

keep cntrynum censusfreq StateHist50s tax_inc_tax tax_trade_tax taxrev_gdp weberian wbstat v2terr v2clrspct v2stfisccap infcap policecap milexpercap milpercap bureau_qual law_order irai_erm irai_qbfm irai_qpa AdmEffic bti_mo year

rename milpercap milcap
rename milexpercap milspend
rename bureau_qual bureauqual
rename law_order laworder
rename censusfreq census
rename taxrev_gdp taxrevgdp
rename tax_inc_tax taxinc
rename tax_trade_tax taxtrade
rename StateHist50s statehist
rename v2clrspct pubadmin
rename infcap infcap

* address two cases where the scores for irai_qpa fall between integers. They are 1.5 for Zimbabwe in 2007 and 2009.  Rounding down to 1.0, since the surrounding scores are all lower than the 1.5.

replace irai_qpa = 1 if cntrynum==193 & (year==2007 | year==2009)

order year cntrynum census statehist taxinc taxtrade taxrevgdp weberian wbstat v2terr pubadmin v2stfisccap infcap policecap milcap milspend bureauqual laworder irai_erm irai_qbfm irai_qpa AdmEffic bti_mo 

sort year cntrynum
saveold "Data/Indicators.dta", replace

